//
//  SetUpTableViewCell.m
//  markmap
//
//  Created by 甘世清 on 2024/4/18.
//

#import "SetUpTableViewCell.h"

@implementation SetUpTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    UIView *bgView = [[UIView alloc]init];
    bgView.layer.cornerRadius = 27;
    bgView.layer.masksToBounds = YES;
    bgView.layer.borderWidth = 1;
    bgView.layer.borderColor = UIColor.whiteColor.CGColor;
    bgView.backgroundColor = SQHexColor(@"#FFFFFF", 0.24);
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(12, 29, 0, 29));
    }];

    [bgView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bgView);
        make.left.equalTo(bgView).offset(20);
    }];
    UIImageView * image = [[UIImageView alloc]init];
    image.image = SQGetImage(@"箭头");
    image.contentMode = UIViewContentModeScaleAspectFit;
    [bgView addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(24);
            make.centerY.equalTo(bgView);
            make.right.equalTo(bgView.mas_right).offset(-16);
    }];
    
    [bgView addSubview:self.rightLabel];
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bgView);
        make.right.equalTo(image.mas_left).offset(-6);
        make.left.equalTo(bgView).offset(80);
    }];
}
- (void)setModel:(InfoModel *)model{
    _model = model;
    self.nameLabel.text = SQNSLocalString(model.leftString);
    if ([model.rightString isNotEmpty]) {
        self.rightLabel.text = model.rightString;
        self.rightLabel.textColor = UIColor.whiteColor;
        if ([model.leftString isEqualToString:@"个人背景"]) {
            self.rightLabel.text = @"";
        }
    } else {
        self.rightLabel.text = SQNSLocalString(@"待完善");
        _rightLabel.textColor = SQColor999999;
    }
    if ([model.leftString isEqualToString:@"相册"]) {
        self.rightLabel.text = @"";
    }
    
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_BOLD(16);
        _nameLabel.textColor = UIColor.whiteColor;
       
    }
    return _nameLabel;
}
- (UILabel *)rightLabel{
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc]init];
        _rightLabel.font = FONT_REGULAR(14);
        _rightLabel.textColor = SQColor999999;
        _rightLabel.textAlignment = NSTextAlignmentRight;
    }
    return _rightLabel;
}
@end
